/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package parcview;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Canvas;

/**
 *
 * @author Malte
 */
public class TrafficLightDraw {
    
    int posX;
    int posY;
    boolean lightState = false;
    boolean enabled = false;
    
    public TrafficLightDraw(int x, int y) {
        this.posX = x;
        this.posY = y;
    }
    
    public void enable(boolean state) {
        enabled = state;
    }
    
    public void setLight(boolean lightState) {
        this.lightState = lightState;
    }
    
    public void drawTrafficLight(GC g, Canvas d) {
        g.setBackground(d.getDisplay().getSystemColor(SWT.COLOR_BLACK));
        g.fillRectangle(this.posX, this.posY, 33 , 67);
        if(!lightState && enabled) {
            g.setBackground(d.getDisplay().getSystemColor(SWT.COLOR_RED));
            g.fillOval(this.posX+6, this.posY+7, 21, 21);
            
        }
        if(lightState && enabled) {
            g.setBackground(d.getDisplay().getSystemColor(SWT.COLOR_GREEN));
            g.fillOval(this.posX+6, this.posY+39, 21, 21);
        }
        
        if(!enabled) {
            g.setBackground(d.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            g.fillOval(this.posX+6, this.posY+7, 21, 21);
            g.setBackground(d.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            g.fillOval(this.posX+6, this.posY+39, 21, 21);
            g.setBackground(d.getDisplay().getSystemColor(SWT.COLOR_BLACK));
            g.fillOval(this.posX+7, this.posY+8, 19, 19);
            g.setBackground(d.getDisplay().getSystemColor(SWT.COLOR_BLACK));
            g.fillOval(this.posX+7, this.posY+40, 19, 19);
        }
        
    }

}
